package com.zjh.admin.service.impl;


import com.zjh.admin.mapper.SysConfigMapper;
import com.zjh.admin.service.SysConfigService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SysConfigServiceImpl implements SysConfigService {

    @Resource
    private SysConfigMapper sysConfigMapper;

    @Override
    public String getConfigByConfigName(String configName) {
        return sysConfigMapper.getConfigByName(configName);
    }

    @Override
    public void saveOrUpdateConfigByConfigName(String configName, String configValue) {
        String value = sysConfigMapper.getConfigByName(configName);
        if (StringUtils.isNotBlank(value)) {
            sysConfigMapper.updateConfigByName(configName, configValue);
        } else {
            sysConfigMapper.insertConfigByName(configName, configValue);
        }
    }

    @Override
    public void deleteConfigByConfigName(String configName) {
        sysConfigMapper.deleteByConfigName(configName);
    }
}
